#include <msp430x20x3.h>
int flag=1;

void main(void){
 int i,j;
 DCOCTL  = CALDCO_1MHZ;     //(1)
 BCSCTL1 = CALBC1_1MHZ;

 WDTCTL = WDT_ADLY_1000;    //(2)
 IE1 |= WDTIE;              //(3)

 P1DIR = 0xFF;              //(4)
 P1OUT = 0;
 P2DIR = 0xFF;
 P2OUT = 0;
 //P1SEL=0x11;             //ACLK(2pin),SMCLK(6pin)
 P1OUT = 0x80;             //(5) 緑が点灯

 while(1){
  for(i=0;i<6;i++) for(j=0; j < 0x7FFF; j++); //(6) wait

  P1OUT=0;                                    //(7) LEDを消灯
  _BIS_SR(LPM3_bits + GIE);                   //(8) LPM3モードに移行
 }
}

#pragma vector=WDT_VECTOR                     //(9)
__interrupt void watchdog_timer(void){

 if(flag==1){                                 //(10)
  P1OUT = 0x40;                               //赤が点灯
  flag=0;
 }else{
  P1OUT = 0x80;                               //緑が点灯
  flag=1;
 }
 _BIC_SR_IRQ(LPM3_bits);                      //(11)
}
